package org.jsets.fastboot.persistent.impl;

import org.jsets.fastboot.persistent.DataFormats;
import org.jsets.fastboot.persistent.IDesensitizeService;
import cn.hutool.core.util.DesensitizedUtil;

public class DesensitizeService implements IDesensitizeService {

	@Override
	public String desensitized(String dataFormat, String plaintext) {
		switch (dataFormat) {
		case DataFormats.USER_NAME_CN:
			return DesensitizedUtil.chineseName(plaintext);
		case DataFormats.ID_CARD_NO:
			return DesensitizedUtil.idCardNum(plaintext, 2, 4);
		case DataFormats.TEL_NO:
			return DesensitizedUtil.fixedPhone(plaintext);
		case DataFormats.MOBIL_NO:
			return DesensitizedUtil.mobilePhone(plaintext);
		case DataFormats.ADDRESS:
			return DesensitizedUtil.address(plaintext, 4);
		case DataFormats.EMAIL:
			return DesensitizedUtil.email(plaintext);
		case DataFormats.PASSWORD:
			return DesensitizedUtil.password(plaintext);
		case DataFormats.CAR_NO:
			return DesensitizedUtil.carLicense(plaintext);
		case DataFormats.BANK_CARD_NO:
			return DesensitizedUtil.bankCard(plaintext);
		default:
			break;
		}
		return DesensitizedUtil.password(plaintext);
	}

	
	
}
